package com.zhanbo.zhanbowymusic.main.featured;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;

import com.mwx.baselib.utils.MLog;
import com.youth.banner.indicator.CircleIndicator;
import com.zhanbo.zhanbowymusic.MainActivity;
import com.zhanbo.zhanbowymusic.R;
import com.zhanbo.zhanbowymusic.databinding.FragmentVipListBinding;
import com.mwx.baselib.base.BaseFragment;
import com.zhanbo.zhanbowymusic.main.featured.adapter.FeaturedHomeNewMusicListAdapter;
import com.zhanbo.zhanbowymusic.main.featured.adapter.FeaturedVIPEveryDayListAdapter;
import com.zhanbo.zhanbowymusic.main.featured.adapter.FeaturedVIPHitListAdapter;
import com.zhanbo.zhanbowymusic.main.featured.adapter.HomeFeaturedBannerAdapter;

import java.util.ArrayList;

/**
 * VIP歌曲列表
 */
public class VipListFragment extends BaseFragment<FragmentVipListBinding> implements View.OnClickListener {


    @Override
    protected Object getLayout() {
        MLog.e("R.layout.fragment_vip_list");

        return R.layout.fragment_vip_list;
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);

    }

    @Override
    protected void init(Bundle savedInstanceState) {
        initView();
        initListener();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        //轮播图
//        ArrayList<Integer> localImages = new ArrayList<Integer>();
//        localImages.add(R.mipmap.banner);
//        localImages.add(R.mipmap.banner2);
//        HomeFeaturedBannerAdapter bannerAdapter = new HomeFeaturedBannerAdapter(_mActivity,localImages);
//        binding.banner.addBannerLifecycleObserver(this)//添加生命周期观察者
//                .setAdapter(bannerAdapter)
//                .setIndicator(new CircleIndicator(_mActivity));
        //vip每日推荐
        ArrayList<Integer> newMusicdata = new ArrayList<>();
        newMusicdata.add(0);
        newMusicdata.add(0);
        newMusicdata.add(0);
        newMusicdata.add(0);
        newMusicdata.add(0);
        newMusicdata.add(0);
        binding.rvVipEveryday.setLayoutManager(new GridLayoutManager(_mActivity,2));
        FeaturedVIPEveryDayListAdapter featuredVIPEveryDayListAdapter = new FeaturedVIPEveryDayListAdapter(_mActivity);
        featuredVIPEveryDayListAdapter.getItems().addAll(newMusicdata);
        binding.rvVipEveryday.setAdapter(featuredVIPEveryDayListAdapter);
        //vip排行榜热歌
        ArrayList<Integer> vipMusicdata = new ArrayList<>();
        vipMusicdata.add(0);
        vipMusicdata.add(0);
        vipMusicdata.add(0);
        binding.rvVipHit.setLayoutManager(new GridLayoutManager(_mActivity,1));
        FeaturedVIPHitListAdapter featuredVIPHitListAdapter = new FeaturedVIPHitListAdapter(_mActivity);
        featuredVIPHitListAdapter.getItems().addAll(vipMusicdata);
        binding.rvVipHit.setAdapter(featuredVIPHitListAdapter);

        binding.rvVipNew.setLayoutManager(new GridLayoutManager(_mActivity,1));
        binding.rvVipNew.setAdapter(featuredVIPHitListAdapter);
    }

    @Override
    protected void initListener() {
    binding.ivVip.setOnClickListener(this);
    }

    public static VipListFragment newInstance() {

        Bundle args = new Bundle();

        VipListFragment fragment = new VipListFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_vip:
                MainActivity mainActivity = (MainActivity) getActivity();
                mainActivity.showBuyVipDialog();
                break;
        }
    }
}